package com.blueheart.easyexcel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import lombok.extern.slf4j.Slf4j;

import java.util.LinkedList;
import java.util.List;

@Slf4j
public class TaxCaseExcelHelper {

    public static void importExcel(String fileName){

        final LinkedList<TaxCaseAnalysisBO> taxCaseAnalysisBOS = new LinkedList<>();

        try(ExcelReader excelReader = EasyExcel.read(fileName, CaseTemplatesBO.class, new CaseTemplateBOReadListener(taxCaseAnalysisBOS))
            .ignoreEmptyRow(true)
            .headRowNumber(1)
            .build()){
            List<ReadSheet> readSheets = excelReader.excelExecutor()
                .sheetList();
            readSheets.stream()
                .skip(1)
                .forEach(sheet -> {
                    excelReader.read(sheet);
                });
            taxCaseAnalysisBOS.stream().forEach(bo -> {
                log.info(bo.toString());
            });
        }
    }

}
